#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

class IsolatedPrimes
{
public:
	string findPrime(int x, int a, int b)
	{
		for (unsigned long long p = a + 2; p <= (unsigned long long) ((1 << 63)
				- 1 - b); p++)
		{
			if (isPrime(p) == false)
				continue;
			int number = count(p, a, b);
			if (number <= x)
			{
				stringstream ss;
				ss << p;
				return ss.str();
			}
		}
	}
	bool isPrime(unsigned long long x)
	{
		for (unsigned long long i = 3; i <= (unsigned long long) sqrt(x); i
				+= 2)
		{
			if (x % i == 0)
				return false;
		}
		return (x % 2 == 0 ? false : true);
	}
	int count(unsigned long long p, int a, int b)
	{
		int ret = 0;
		for (unsigned long long i = p - a; i <= (unsigned long long) p + b; i++)
		{
			if (isPrime(i))
				ret++;
		}
		return ret;
	}
};
